package com.example.farmeri.presenter.farm_manager;

import com.example.farmeri.data.DataParam;
import com.example.farmeri.presenter.base.BasePresenter;
import com.example.farmeri.tools.ResponseUtils;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.annotations.NonNull;
import okhttp3.FormBody;
import okhttp3.RequestBody;

/**
 * 暂无作用
 */
public class FarmManagerPresenter extends BasePresenter<IFarmManagerContract> {


    public FarmManagerPresenter(IFarmManagerContract view) {
        super(view);
    }

    public void deleteFarmManager(String farm_manager_id){
        RequestBody requestBody = new FormBody.Builder()
                .add("farm_own_id", DataParam.getUserInfo().getId())
                .add("farm_manager_id",farm_manager_id)
                .build();
        getAPI()
                .deleteFarmManager(requestBody)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new SimpleObservable<ResponseUtils>() {
                    @Override
                    public void onSuccess(@NonNull ResponseUtils responseUtils) {
                        if (responseUtils.getCode() == 200){
                            getView().deleteFarmSuccess();
                        }else{
                            getView().showMessage(responseUtils.getMessage());
                        }
                    }

                    @Override
                    public void onError(String msg) {
                        getView().showMessage("删除管理员失败");
                    }
                });
    }

}
